package com.itheima.demo;

import java.io.*;
import java.util.ArrayList;
import java.util.Set;
import java.util.TreeSet;

public class Demo06 {
    public static void main(String[] args) throws IOException {
        //字符输入缓冲流
        BufferedReader br = new BufferedReader(new FileReader("F:\\aaa.txt"));



        Set<Integer> treeSet = new TreeSet<>();
        int line;
        System.out.print("读到的内容:");
        while ((line = br.read())!=-1){
            String s = String.valueOf((char) line);
            int i = Integer.parseInt(s);
            treeSet.add(i);
            System.out.print(i+" ");
        }
        br.close();

        System.out.println();

        //字符输出缓冲流
        BufferedWriter bw = new BufferedWriter(new FileWriter("day12_IO\\a.txt"));
        System.out.print("排序的内容:");
        for (Integer integer : treeSet) {
            String s = String.valueOf(integer);
            bw.write(s+" ");
            System.out.print(s+" ");
        }
        bw.close();


    }
}
